package com.file;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStreamReader;

public class 流转换 {
    public void nochange(){
        FileInputStream input = null;
        try {
            //utf-8
            input = new FileInputStream("d:\\7788\\fuck\\girl.txt");
            int i ;
            byte[] b = new byte[1024];
            while ((i = input.read(b))!= -1){
                String s = new String(b,"utf-8");
                System.out.println(s);
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
        }
    }
    public void change(){
        FileInputStream in = null;
        InputStreamReader reader = null;
        try {
            in = new FileInputStream("d:\\7788\\fuck\\girl.txt");
            reader = new InputStreamReader(in,"UTF-8");
            char[] c = new char[1024];
            int i;
            while ((i=reader.read(c)) != -1){
                String s = new String(c);
                System.out.println(s);
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
        }
    }


    public static void main(String[] args) {
        流转换 stream = new 流转换();
        stream.nochange();
        stream.change();
    }
}
